#ifndef __PNUPDATESERVICE_H__
#define __PNUPDATESERVICE_H__

/**
*@file       pnUpdateService.h
*@brief      net work service
*
*@author     graywind
*@version    1.0.0.0
*@data       2011/11/16
*/

#include <list>
#include "boost/thread.hpp"
#include "boost/asio.hpp"

///net service relative
namespace pnNetlib
{
	///@brief net work service class
	class pnUpdateService
	{
	private:
		///@brief      threads list type
		typedef std::list<boost::thread*>  ThreadList;

	private:
		///@brief     started yet
		bool                            m_bIsStart;
		///@brief     io service
		boost::asio::io_service&        m_ioService;

		boost::asio::io_service::work   m_work;
	    ///@brief     count of the threads that be used to update the action
		int                             m_iThreadNum;
		///@brief     list of threads
		ThreadList                      m_listThreads;

	private:
		///@breif    vanish clear
		void vanish();

	public:
		///@brief    constructor
		///param[in] ioService                  boost asio io service object
		///param[in] update_thread_num          count of threads that be used to update service
		pnUpdateService(boost::asio::io_service& ioService, int update_thread_num);
		///@brief    deconsrtuctor
		~pnUpdateService();

	public:
		///@brief    start yet(read-only)
		const bool  is_start() const;
		///@brief    start service
		void        start();
		///@breif    terminate service
		void        terminate();
	};

	/***************************************************************************************************************************/
	inline
	const
	bool
	pnUpdateService::is_start() const
	{
		return m_bIsStart;
	}

	/***************************************************************************************************************************/
};

#endif